package com.api.shopapi.mapper;

import com.api.shopapi.entity.ElderlyCheckinAssess;
import com.api.shopapi.entity.ElderlyCheckinAssessWait;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface ElderlyCheckinAssessWaitMapper {

    @Insert("insert into elderly_checkin_assess_wait " +
            "(ElderlyCheckinAssessWaitCode," +
            "ElderlyCode," +
            "InstitutionCode," +
            "GovernmentCode," +
            "CreateTime" +
            ")value(" +
            "#{elderlyCheckinAssessWait.ElderlyCheckinAssessWaitCode}," +
            "#{elderlyCheckinAssessWait.ElderlyCode}," +
            "#{elderlyCheckinAssessWait.InstitutionCode}," +
            "#{elderlyCheckinAssessWait.GovernmentCode}," +
            "#{elderlyCheckinAssessWait.CreateTime}" +
            ")")
    int insert(@Param("elderlyCheckinAssessWait") ElderlyCheckinAssessWait elderlyCheckinAssessWait);

    @Delete("delete from elderly_checkin_assess_wait where elderlyCheckinAssessWaitCode=#{elderlyCheckinAssessWaitCode}")
    int delete(@Param("elderlyCheckinAssessWaitCode") String elderlyCheckinAssessWaitCode);

    @Update("update elderly_checkin_assess_wait" +
            " set" +
            " ElderlyCode=#{elderlyCheckinAssess.ElderlyCode}" +
            " where elderlyCheckinAssessWaitCode=#{elderlyCheckinAssessWait.elderlyCheckinAssessWaitCode}")
    int update(@Param("elderlyCheckinAssessWait") ElderlyCheckinAssessWait elderlyCheckinAssessWait);

    @Select("select * from elderly_checkin_assess_wait where elderlyCheckinAssessWaitCode=#{elderlyCheckinAssessWaitCode} limit 1")
    ElderlyCheckinAssessWait getByCode(@Param("elderlyCheckinAssessWaitCode") String elderlyCheckinAssessWaitCode);

    @Select("select * from elderly_checkin_assess_wait where InstitutionCode=#{institutionCode} order by CreateTime desc")
    List<ElderlyCheckinAssessWait> listByInstitutionCode(@Param("institutionCode") String institutionCode);

    @Select("select * from elderly_checkin_assess_wait where governmentCode=#{governmentCode} order by CreateTime desc")
    List<ElderlyCheckinAssessWait> listByGovCode(@Param("governmentCode") String governmentCode);

    @Select("select * from elderly_checkin_assess_wait where v=#{elderlyCode} order by CreateTime desc")
    List<ElderlyCheckinAssessWait> listByElderlyCode(@Param("elderlyCode") String elderlyCode);


}
